home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 21 / CU Amiga Magazine's Super CD-ROM 21 (1998)(EMAP Images)(GB)[!][issue 1998-04].iso / CUCD / Programming / MCC_SettingsWindow / Developer / C / Examples / SettingsWindow-Demo.c
Encoding:
C/C++ Source or Header  |  1997-12-15  |  28.6 KB  |  1,200 lines

  1. /*
  2. ** SettingsWindow-Demo.c - V0.40
  3. **
  4. ** Written by Ingo Weinhold.
  5. **
  6. ** This program demonstrates the usage of the SettingsWindow.mcc.
  7. ** It's written using Maxon C++ 3.0. You might need to change some
  8. ** parts (especially the include section).
  9. **
  10. ** I hope you are not afraid seeing more than 1000 lines of code - hey,
  11. ** a lot of them are comments. The three subclasses are only there to
  12. ** make it possible to edit the list contents' comfortably - they are
  13. ** not needed to use SettingsWindow.mcc.
  14. */
  15.  
  16.  
  17. /* MUI */
  18.  
  19. #include <libraries/mui.h>
  20. #include <MUI/SettingsWindow_mcc.h>
  21.  
  22.  
  23. /* System */
  24.  
  25. #include <libraries/asl.h>
  26. #include <libraries/gadtools.h>
  27.  
  28.  
  29. /* Prototypes */
  30.  
  31. #include <clib/alib_protos.h>
  32. #include <clib/exec_protos.h>
  33. #include <clib/utility_protos.h>
  34. #include <clib/muimaster_protos.h>
  35.  
  36.  
  37. /* ANSI C */
  38.  
  39. #include <stdlib.h>
  40. #include <string.h>
  41. #include <stdio.h>
  42. #include <wbstartup.h>
  43.  
  44.  
  45. /* Compiler specific stuff */
  46.  
  47. #define REG(x) register __ ## x
  48. #define ASM
  49. #define SAVEDS
  50.  
  51.  
  52. /* Useful stuff */
  53.  
  54. #ifndef TAG_INGO
  55. #define TAG_INGO ((0x2c01<<16) | TAG_USER)
  56. #endif
  57.  
  58. #define FChild (MUIA_Family_Child)
  59.  
  60. #ifndef MAKE_ID
  61. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  62. #endif
  63.  
  64.  
  65. /* Pragmas */
  66.  
  67. #include <pragma/exec_lib.h>
  68.  
  69.  
  70. extern struct Library *SysBase;
  71. struct Library *MUIMasterBase,*UtilityBase;
  72.  
  73.  
  74. struct MUI_CustomClass *EditListClass=NULL,*StringListClass=NULL,
  75.     *ComplexListClass=NULL;
  76.  
  77.  
  78. LONG __stack = 8192;
  79.  
  80.  
  81. /*    Menu Return-Values */
  82.  
  83. #define menu_quit                0x01
  84. #define menu_iconify            0x02
  85. #define menu_settings        0x03
  86. #define menu_settingsmui    0x04
  87. #define menu_aboutmui        0x05
  88.  
  89.  
  90. /* ID's for settings items */
  91.  
  92. #define setid_number        0x01
  93. #define setid_dir            0x02
  94. #define setid_pen            0x03
  95. #define setid_strlist    0x04
  96. #define setid_cpxlist    0x05
  97.  
  98.  
  99. STRPTR regtitles[]= {"Simple Types","StringList","ComplexList",NULL};
  100.  
  101. static const char introtext[] =
  102. "\tThis little application demonstrates the features of \
  103. SettingsWindow.mcc. It is especially thought for programmers who want \
  104. to take a look at it's source code.\n\tThe main window displays the \
  105. current settings. You can change some simple items, a list of strings \
  106. and a rather complex list.";
  107.  
  108.  
  109.  
  110. /* Supporting Function for Lists */
  111.  
  112.  
  113. ULONG getactive(Object *obj, APTR &active)
  114. {
  115.     ULONG pos;
  116.  
  117.     get(obj,MUIA_List_Active,&pos);
  118.  
  119.     if (pos!=MUIV_List_Active_Off)
  120.         {
  121.         DoMethod(obj,MUIM_List_GetEntry,pos,&active);
  122.         }
  123.  
  124.     return(pos);
  125. }
  126.  
  127.  
  128.  
  129. /******************
  130. *  EditListClass  *
  131. ******************/
  132.  
  133. /* This class provides four methods for editing lists. */
  134.  
  135.  
  136. #define EditListObject    NewObject(EditListClass->mcc_Class,NULL
  137.  
  138. /* Instance Data */
  139.  
  140. struct EditList_Data
  141. {
  142. };
  143.  
  144. #define MUI_EditList_dummy                (TAG_INGO + 0x0000)
  145.  
  146. /* Attributes */
  147.  
  148. #define MUIA_EditList_List                (MUI_EditList_dummy + 0x01)
  149.  
  150. /* Methods */
  151.  
  152. #define MUIM_EditList_AddEntry        (MUI_EditList_dummy + 0x01)
  153. #define MUIM_EditList_CloneEntry        (MUI_EditList_dummy + 0x02)
  154. #define MUIM_EditList_RemEntry        (MUI_EditList_dummy + 0x03)
  155. #define MUIM_EditList_ActiveChanged    (MUI_EditList_dummy + 0x04)
  156.  
  157. /* Method Parameter Structures */
  158.  
  159. struct MUIP_EditList_AddEntry                { ULONG MethodID; };
  160. struct MUIP_EditList_CloneEntry            { ULONG MethodID; };
  161. struct MUIP_EditList_RemEntry                { ULONG MethodID; };
  162. struct MUIP_EditList_ActiveChanged        { ULONG MethodID; };
  163.  
  164.  
  165. static ULONG EditList_New(struct IClass *cl,Object *obj,struct opSet *msg)
  166. {
  167.     Object *grp_buttons,*bu_add,*bu_clone,*bu_rem;
  168.     struct TagItem *ti;
  169.     BOOL success=FALSE;
  170.  
  171.     if (ti=FindTagItem(MUIA_EditList_List,msg->ops_AttrList))
  172.         {
  173.         ti->ti_Tag=Child;
  174.  
  175.         if (obj=(Object *)DoSuperMethodA(cl,obj,(APTR)msg))
  176.             {
  177.             if (grp_buttons=HGroup,
  178.                     Child, bu_add=SimpleButton("Add"),
  179.                     Child, bu_clone=SimpleButton("Clone"),
  180.                     Child, bu_rem=SimpleButton("Remove"),
  181.                     End)
  182.                 {
  183.                 DoMethod(obj,OM_ADDMEMBER,grp_buttons);
  184.  
  185.                 DoMethod(bu_add,MUIM_Notify,MUIA_Pressed,FALSE,
  186.                     obj,1,MUIM_EditList_AddEntry);
  187.                 DoMethod(bu_clone,MUIM_Notify,MUIA_Pressed,FALSE,
  188.                     obj,1,MUIM_EditList_CloneEntry);
  189.                 DoMethod(bu_rem,MUIM_Notify,MUIA_Pressed,FALSE,
  190.                     obj,1,MUIM_EditList_RemEntry);
  191.  
  192.                 DoMethod(obj,MUIM_Notify,MUIA_List_Active,MUIV_EveryTime,
  193.                     obj,1,MUIM_EditList_ActiveChanged);
  194.  
  195.                 success=TRUE;
  196.                 }
  197.             }
  198.         }
  199.  
  200.     if (!success)
  201.         {
  202.         if (obj)
  203.             {
  204.             CoerceMethod(cl,obj,OM_DISPOSE);
  205.             obj=NULL;
  206.             }
  207.         }
  208.  
  209.     return((ULONG)obj);
  210. }
  211.  
  212.  
  213. static ULONG EditList_AddEntry(struct IClass *cl,Object *obj,struct MUIP_EditList_AddEntry *msg)
  214. {
  215.     struct EditList_Data *data=INST_DATA(cl,obj);
  216.  
  217.     DoMethod(obj,MUIM_List_InsertSingle,NULL,MUIV_List_Insert_Bottom);
  218.     set(obj,MUIA_List_Active,MUIV_List_Active_Bottom);
  219.  
  220.     return(TRUE);
  221. }
  222.  
  223.  
  224. static ULONG EditList_CloneEntry(struct IClass *cl,Object *obj,struct MUIP_EditList_CloneEntry *msg)
  225. {
  226.     struct EditList_Data *data=INST_DATA(cl,obj);
  227.     APTR active;
  228.  
  229.     if (getactive(obj,active)!=MUIV_List_Active_Off)
  230.         {
  231.         DoMethod(obj,MUIM_List_InsertSingle,active,MUIV_List_Insert_Bottom);
  232.         }
  233.  
  234.     return(TRUE);
  235. }
  236.  
  237.  
  238. static ULONG EditList_RemEntry(struct IClass *cl,Object *obj,struct MUIP_EditList_RemEntry *msg)
  239. {
  240.     struct EditList_Data *data=INST_DATA(cl,obj);
  241.     ULONG pos;
  242.  
  243.     get(obj,MUIA_List_Active,&pos);
  244.  
  245.     if (pos!=MUIV_List_Active_Off)
  246.         {
  247.         DoMethod(obj,MUIM_List_Remove,pos);
  248.         }
  249.  
  250.     return(TRUE);
  251. }
  252.  
  253.  
  254. static SAVEDS ASM ULONG EditList_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  255. {
  256.     switch (msg->MethodID)
  257.         {
  258.         case OM_NEW                                : return(EditList_New                (cl,obj,(APTR)msg));
  259.         case MUIM_EditList_AddEntry        : return(EditList_AddEntry            (cl,obj,(APTR)msg));
  260.         case MUIM_EditList_CloneEntry        : return(EditList_CloneEntry        (cl,obj,(APTR)msg));
  261.         case MUIM_EditList_RemEntry        : return(EditList_RemEntry            (cl,obj,(APTR)msg));
  262.         }
  263.  
  264.     return(DoSuperMethodA(cl,obj,msg));
  265. }
  266.  
  267.  
  268.  
  269. /********************
  270. *  StringListClass  *
  271. ********************/
  272.  
  273. /* This class is a subclass of EditListClass. It features a list and a
  274. ** StringObject for editing the lists entries. The Construct/Destruct-
  275. ** Hooks are necessary to handle NULL pointers given from
  276. ** MUIM_EditList_AddEntry. Setting MUIA_StringList_String changes the
  277. ** active entry.
  278. */
  279.  
  280. #define StringListObject    NewObject(StringListClass->mcc_Class,NULL
  281.  
  282. /* Instance Data */
  283.  
  284. struct StringList_Data
  285. {
  286.     Object *strobj;
  287. };
  288.  
  289. #define MUI_StringList_dummy                (TAG_INGO + 0x0010)
  290.  
  291. /* Attributes */
  292.  
  293. #define MUIA_StringList_String            (MUI_StringList_dummy + 0x01)
  294.  
  295. /* Methods */
  296.  
  297. /* Method Parameter Structures */
  298.  
  299.  
  300. /* Construct/DestructHook functions */
  301.  
  302. static APTR ConstructFunc_Strings(REG(a2) APTR pool, REG(a1) STRPTR str)
  303. {
  304.     STRPTR entry=NULL;
  305.  
  306.     if (entry=AllocPooled(pool,40))
  307.         {
  308.         if (str) strcpy(entry,str);
  309.         }
  310.  
  311.     return(entry);
  312. }
  313.  
  314.  
  315. static VOID DestructFunc_Strings(REG(a2) APTR pool, REG(a1) STRPTR *entry)
  316. {
  317.     if (entry)
  318.         {
  319.         FreePooled(pool,entry,40);
  320.         }
  321. }
  322.  
  323.  
  324. static struct Hook ConstructHook_Strings = { { NULL,NULL },(VOID *)ConstructFunc_Strings,NULL,NULL};
  325. static struct Hook DestructHook_Strings = { { NULL,NULL },(VOID *)DestructFunc_Strings,NULL,NULL};
  326.  
  327.  
  328. static ULONG StringList_New(struct IClass *cl,Object *obj,struct opSet *msg)
  329. {
  330.     struct StringList_Data *data;
  331.     TagItem itaglist[]={
  332.         MUIA_EditList_List, NULL,
  333.         Child, NULL,
  334.         TAG_MORE,NULL};
  335.  
  336.     BOOL success=FALSE;
  337.  
  338.     /* Create Listview and StringObject */
  339.  
  340.      itaglist[0].ti_Data=(ULONG)ListviewObject,
  341.         MUIA_Listview_Input, TRUE,
  342.         MUIA_Listview_DragType, MUIV_Listview_DragType_Immediate,
  343.         MUIA_Listview_List, ListObject,
  344.             MUIA_Frame, MUIV_Frame_InputList,
  345.             MUIA_List_DragSortable, TRUE,
  346.             MUIA_List_ConstructHook, &ConstructHook_Strings,
  347.             MUIA_List_DestructHook, &DestructHook_Strings,
  348.             End,
  349.         End,
  350.  
  351.     itaglist[1].ti_Data=(ULONG)StringObject,
  352.         MUIA_Frame, MUIV_Frame_String,
  353.         MUIA_String_MaxLen, 40,
  354.         End,
  355.  
  356.     /* Insert the additional tags */
  357.  
  358.     itaglist[sizeof(itaglist)/sizeof(struct TagItem)-1].ti_Data=(ULONG)msg->ops_AttrList;
  359.     msg->ops_AttrList=itaglist;
  360.  
  361.     if (obj=(Object *)DoSuperMethodA(cl,obj,(APTR)msg))
  362.         {
  363.         data=INST_DATA(cl,obj);
  364.         data->strobj=(Object *)itaglist[1].ti_Data;
  365.  
  366.         /* the notification that causes modifying the active entry */
  367.  
  368.         DoMethod(data->strobj,MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,
  369.             obj,3,MUIM_Set,MUIA_StringList_String,MUIV_TriggerValue);
  370.  
  371.         success=TRUE;
  372.         }
  373.  
  374.     if (!success)
  375.         {
  376.         if (obj)
  377.             {
  378.             CoerceMethod(cl,obj,OM_DISPOSE);
  379.             obj=NULL;
  380.             }
  381.         }
  382.  
  383.     return((ULONG)obj);
  384. }
  385.  
  386.  
  387. static ULONG StringList_Set(struct IClass *cl,Object *obj,struct opSet *msg)
  388. {
  389.     struct StringList_Data *data=INST_DATA(cl,obj);
  390.  
  391.     struct TagItem *ti;
  392.  
  393.     if (ti=FindTagItem(MUIA_StringList_String,msg->ops_AttrList))
  394.         {
  395.         ULONG pos;
  396.         STRPTR active;
  397.  
  398.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  399.             {
  400.             strcpy(active,(STRPTR)ti->ti_Data);
  401.             DoMethod(obj,MUIM_List_Redraw,pos);
  402.             }
  403.         }
  404.  
  405.     return(DoSuperMethodA(cl,obj,(APTR)msg));
  406. }
  407.  
  408.  
  409. static ULONG StringList_ActiveChanged(struct IClass *cl,Object *obj,struct MUIP_EditList_ActiveChanged *msg)
  410. {
  411.     struct StringList_Data *data=INST_DATA(cl,obj);
  412.     STRPTR active;
  413.  
  414.     if (getactive(obj,active)!=MUIV_List_Active_Off)
  415.         {
  416.         set(data->strobj,MUIA_String_Contents,active);
  417.         set(_win(obj),MUIA_Window_ActiveObject,data->strobj);
  418.         }
  419.  
  420.     return(TRUE);
  421. }
  422.  
  423.  
  424. static SAVEDS ASM ULONG StringList_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  425. {
  426.     switch (msg->MethodID)
  427.         {
  428.         case OM_NEW                                    : return(StringList_New                    (cl,obj,(APTR)msg));
  429.         case OM_SET                                    : return(StringList_Set                    (cl,obj,(APTR)msg));
  430.         case MUIM_EditList_ActiveChanged        : return(StringList_ActiveChanged    (cl,obj,(APTR)msg));
  431.         }
  432.  
  433.     return(DoSuperMethodA(cl,obj,msg));
  434. }
  435.  
  436.  
  437.  
  438. /*********************
  439. *  ComplexListClass  *
  440. *********************/
  441.  
  442. /* This class is a subclass of EditListClass. It features a list and
  443. ** six objects for editing the lists entries. Setting any of the
  444. ** six attributes changes the related item of the active entry.
  445. */
  446.  
  447. /* the cycle entries */
  448.  
  449. STRPTR amigas[] = {"A500","A600","A1200","A2000","A3000","A4000",NULL};
  450. STRPTR cpus[] = {"68000","68020","68030","68040","68060",NULL};
  451. STRPTR tshirts[] = {"S","M","L","XL","XXL",NULL};
  452.  
  453. #define amiga_size    (sizeof(struct amiga)+sizeof(struct cpu)+sizeof(struct owner)+40)
  454.  
  455.  
  456. /* the type of the list entries */
  457.  
  458. struct cpu
  459. {
  460.     UBYTE cpu;
  461.     UBYTE pad;
  462.     UWORD freq;
  463. };
  464.  
  465. struct owner
  466. {
  467.     STRPTR name;
  468.     UWORD age;
  469.     UBYTE tshirt;
  470. };
  471.  
  472. struct amiga
  473. {
  474.     UWORD amiga;
  475.     struct cpu *cpu;
  476.     struct owner *owner;
  477. };
  478.  
  479.  
  480. /* This is the array describing the List's entries (struct amiga). */
  481.  
  482. static UWORD amiga_des[]=
  483. {
  484.     SWIS_STRUCT,                                    /* struct amiga */
  485.         SWIS_WORD,                                    /* UWORD amiga */
  486.  
  487.         SWIS_POINTER, SWIS_STRUCT,                /* pointer to struct cpu */
  488.             SWIS_BYTE,                                /* UBYTE cpu */
  489.             SWIS_BYTE,                                /* UBYTE pad */
  490.             SWIS_WORD,                                /* UWORD freq */
  491.             SWIS_END,                                /* end of struct cpu */
  492.  
  493.         SWIS_POINTER, SWIS_STRUCT,                /* pointer to struct owner */
  494.             SWIS_POINTER, SWIS_STRING,-1,        /* pointer to string name, length not limited */
  495.             SWIS_WORD,                                /* UWORD age */
  496.             SWIS_BYTE,                                /* UBYTE tshirt */
  497.             SWIS_END,                                /* end of struct owner */
  498.         SWIS_END                                        /* end of struct amiga */
  499. };
  500.  
  501.  
  502. #define ComplexListObject    NewObject(ComplexListClass->mcc_Class,NULL
  503.  
  504. /* Instance Data */
  505.  
  506. struct ComplexList_Data
  507. {
  508.     Object *amigaobj,*cpuobj,*freqobj,*nameobj,*ageobj,*tshirtobj;
  509. };
  510.  
  511. #define MUI_ComplexList_dummy                (TAG_INGO + 0x0020)
  512.  
  513. /* Attributes */
  514.  
  515. #define MUIA_ComplexList_Amiga            (MUI_ComplexList_dummy + 0x01)
  516. #define MUIA_ComplexList_CPU                (MUI_ComplexList_dummy + 0x02)
  517. #define MUIA_ComplexList_Freq                (MUI_ComplexList_dummy + 0x03)
  518. #define MUIA_ComplexList_Name                (MUI_ComplexList_dummy + 0x04)
  519. #define MUIA_ComplexList_Age                (MUI_ComplexList_dummy + 0x05)
  520. #define MUIA_ComplexList_TShirt            (MUI_ComplexList_dummy + 0x06)
  521.  
  522. /* Methods */
  523.  
  524. /* Method Parameter Structures */
  525.  
  526.  
  527. /* Construct/Destruct/DisplayHook functions */
  528.  
  529. static APTR ConstructFunc_Complex(REG(a2) APTR pool,
  530.     REG(a1) struct amiga *amiga)
  531. {
  532.     struct amiga *entry=NULL;
  533.     ULONG i;
  534.  
  535.     if (entry=AllocPooled(pool,amiga_size))
  536.         {
  537.         for (i=0;i<amiga_size;i++) ((UBYTE *)entry)[i]=0;
  538.  
  539.         if (amiga) entry->amiga=amiga->amiga;
  540.         entry->cpu=(APTR)((ULONG)entry+sizeof(struct amiga));
  541.         entry->owner=(APTR)((ULONG)entry->cpu+sizeof(struct cpu));
  542.  
  543.         if (amiga)
  544.             {
  545.             *(entry->cpu)=*(amiga->cpu);
  546.             *(entry->owner)=*(amiga->owner);
  547.             }
  548.  
  549.         entry->owner->name=(APTR)((ULONG)entry->owner+sizeof(struct owner));
  550.  
  551.         if (amiga) strcpy(entry->owner->name,amiga->owner->name);
  552.         }
  553.  
  554.     return(entry);
  555. }
  556.  
  557.  
  558. static VOID DestructFunc_Complex(REG(a2) APTR pool, REG(a1) amiga *entry)
  559. {
  560.     if (entry)
  561.         {
  562.         FreePooled(pool,entry,amiga_size);
  563.         }
  564. }
  565.  
  566.  
  567. static LONG DisplayFunc_Complex(REG(a2) char **array, REG(a1) struct amiga *entry)
  568. {
  569.     static char buf1[5],buf2[5];
  570.  
  571.  
  572.     if (entry==NULL)
  573.         {
  574.         /* Titelzeile */
  575.  
  576.         *array++ = "\033bAmiga";
  577.         *array++ = "\033bCPU";
  578.         *array++ = "\033bFrequency (MHz)";
  579.         *array++ = "\033bOwner";
  580.         *array++ = "\033bAge";
  581.         *array++ = "\033bTShirt Size";
  582.         }
  583.     else
  584.         {
  585.         sprintf(buf1,"%ld",entry->cpu->freq);
  586.         sprintf(buf2,"%ld",entry->owner->age);
  587.  
  588.         *array++ = amigas[entry->amiga];
  589.         *array++ = cpus[entry->cpu->cpu];
  590.         *array++ = buf1;
  591.         *array++ = entry->owner->name;
  592.         *array++ = buf2;
  593.         *array++ = tshirts[entry->owner->tshirt];
  594.         }
  595.  
  596.     return(0);
  597. }
  598.  
  599.  
  600. static struct Hook ConstructHook_Complex = { { NULL,NULL },(VOID *)ConstructFunc_Complex,NULL,NULL};
  601. static struct Hook DestructHook_Complex = { { NULL,NULL },(VOID *)DestructFunc_Complex,NULL,NULL};
  602. static struct Hook DisplayHook_Complex = { { NULL,NULL },(VOID *)DisplayFunc_Complex,NULL,NULL};
  603.  
  604.  
  605. static ULONG ComplexList_New(struct IClass *cl,Object *obj,struct opSet *msg)
  606. {
  607.     struct ComplexList_Data *data;
  608.     Object *amigaobj,*cpuobj,*freqobj,*nameobj,*ageobj,*tshirtobj;
  609.     TagItem itaglist[]={
  610.         MUIA_EditList_List, NULL,
  611.         TAG_MORE,NULL};
  612.  
  613.     BOOL success=FALSE;
  614.  
  615.     /* Create the Listview and the other objects */
  616.  
  617.      itaglist[0].ti_Data=(ULONG)HGroup,
  618.         Child, ListviewObject,
  619.             MUIA_Listview_Input, TRUE,
  620.             MUIA_Listview_DragType, MUIV_Listview_DragType_Immediate,
  621.             MUIA_Listview_List, ListObject,
  622.                 MUIA_Frame, MUIV_Frame_InputList,
  623.                 MUIA_List_DragSortable, TRUE,
  624.                 MUIA_List_ConstructHook, &ConstructHook_Complex,
  625.                 MUIA_List_DestructHook, &DestructHook_Complex,
  626.                 MUIA_List_DisplayHook, &DisplayHook_Complex,
  627.                 MUIA_List_Format, ",,,,,",
  628.                 MUIA_List_Title, TRUE,
  629.                 End,
  630.             End,
  631.  
  632.         Child, ColGroup(2),
  633.             Child, Label("Computer:"),
  634.             Child, amigaobj=MUI_MakeObject(MUIO_Cycle,NULL,amigas),
  635.             Child, VSpace(0), Child, VSpace(0),
  636.  
  637.             Child, Label("CPU:"),
  638.             Child, cpuobj=MUI_MakeObject(MUIO_Cycle,NULL,cpus),
  639.             Child, VSpace(0), Child, VSpace(0),
  640.  
  641.             Child, Label("Frequency (MHz):"),
  642.             Child, freqobj=SliderObject,
  643.                 MUIA_Numeric_Min, 1,
  644.                 MUIA_Numeric_Max, 200,
  645.                 End,
  646.             Child, VSpace(0), Child, VSpace(0),
  647.  
  648.             Child, Label("Owner:"),
  649.             Child, nameobj=StringObject,
  650.                 MUIA_Frame, MUIV_Frame_String,
  651.                 MUIA_String_MaxLen, 40,
  652.                 End,
  653.             Child, VSpace(0), Child, VSpace(0),
  654.  
  655.             Child, Label("Age:"),
  656.             Child, ageobj=SliderObject,
  657.                 MUIA_Numeric_Min, 1,
  658.                 MUIA_Numeric_Max, 100,
  659.                 End,
  660.             Child, VSpace(0), Child, VSpace(0),
  661.  
  662.             Child, Label("TShirt Size:"),
  663.             Child, tshirtobj=MUI_MakeObject(MUIO_Cycle,NULL,tshirts),
  664.             End,
  665.         End,
  666.  
  667.     /* Insert the additional tags */
  668.  
  669.     itaglist[sizeof(itaglist)/sizeof(struct TagItem)-1].ti_Data=(ULONG)msg->ops_AttrList;
  670.     msg->ops_AttrList=itaglist;
  671.  
  672.     if (obj=(Object *)DoSuperMethodA(cl,obj,(APTR)msg))
  673.         {
  674.         data=INST_DATA(cl,obj);
  675.         data->amigaobj=amigaobj;
  676.         data->cpuobj=cpuobj;
  677.         data->freqobj=freqobj;
  678.         data->nameobj=nameobj;
  679.         data->ageobj=ageobj;
  680.         data->tshirtobj=tshirtobj;
  681.  
  682.         /* the notifications that cause modifying the active entry */
  683.  
  684.         DoMethod(amigaobj,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,
  685.             obj,3,MUIM_Set,MUIA_ComplexList_Amiga,MUIV_TriggerValue);
  686.         DoMethod(cpuobj,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,
  687.             obj,3,MUIM_Set,MUIA_ComplexList_CPU,MUIV_TriggerValue);
  688.         DoMethod(freqobj,MUIM_Notify,MUIA_Numeric_Value,MUIV_EveryTime,
  689.             obj,3,MUIM_Set,MUIA_ComplexList_Freq,MUIV_TriggerValue);
  690.         DoMethod(nameobj,MUIM_Notify,MUIA_String_Contents,MUIV_EveryTime,
  691.             obj,3,MUIM_Set,MUIA_ComplexList_Name,MUIV_TriggerValue);
  692.         DoMethod(ageobj,MUIM_Notify,MUIA_Numeric_Value,MUIV_EveryTime,
  693.             obj,3,MUIM_Set,MUIA_ComplexList_Age,MUIV_TriggerValue);
  694.         DoMethod(tshirtobj,MUIM_Notify,MUIA_Cycle_Active,MUIV_EveryTime,
  695.             obj,3,MUIM_Set,MUIA_ComplexList_TShirt,MUIV_TriggerValue);
  696.  
  697.         success=TRUE;
  698.         }
  699.  
  700.     if (!success)
  701.         {
  702.         if (obj)
  703.             {
  704.             CoerceMethod(cl,obj,OM_DISPOSE);
  705.             obj=NULL;
  706.             }
  707.         }
  708.  
  709.     return((ULONG)obj);
  710. }
  711.  
  712.  
  713. static ULONG ComplexList_Set(struct IClass *cl,Object *obj,struct opSet *msg)
  714. {
  715.     struct ComplexList_Data *data=INST_DATA(cl,obj);
  716.  
  717.     struct TagItem *ti;
  718.     ULONG pos;
  719.     struct amiga *active;
  720.  
  721.     if (ti=FindTagItem(MUIA_ComplexList_Amiga,msg->ops_AttrList))
  722.         {
  723.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  724.             {
  725.             active->amiga=(UWORD)ti->ti_Data;
  726.             DoMethod(obj,MUIM_List_Redraw,pos);
  727.             }
  728.         }
  729.  
  730.     if (ti=FindTagItem(MUIA_ComplexList_CPU,msg->ops_AttrList))
  731.         {
  732.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  733.             {
  734.             active->cpu->cpu=(UBYTE)ti->ti_Data;
  735.             DoMethod(obj,MUIM_List_Redraw,pos);
  736.             }
  737.         }
  738.  
  739.     if (ti=FindTagItem(MUIA_ComplexList_Freq,msg->ops_AttrList))
  740.         {
  741.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  742.             {
  743.             active->cpu->freq=(UWORD)ti->ti_Data;
  744.             DoMethod(obj,MUIM_List_Redraw,pos);
  745.             }
  746.         }
  747.  
  748.     if (ti=FindTagItem(MUIA_ComplexList_Name,msg->ops_AttrList))
  749.         {
  750.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  751.             {
  752.             strcpy(active->owner->name,(STRPTR)ti->ti_Data);
  753.             DoMethod(obj,MUIM_List_Redraw,pos);
  754.             }
  755.         }
  756.  
  757.     if (ti=FindTagItem(MUIA_ComplexList_Age,msg->ops_AttrList))
  758.         {
  759.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  760.             {
  761.             active->owner->age=(UWORD)ti->ti_Data;
  762.             DoMethod(obj,MUIM_List_Redraw,pos);
  763.             }
  764.         }
  765.  
  766.     if (ti=FindTagItem(MUIA_ComplexList_TShirt,msg->ops_AttrList))
  767.         {
  768.         if ((pos=getactive(obj,active))!=MUIV_List_Active_Off)
  769.             {
  770.             active->owner->tshirt=(UBYTE)ti->ti_Data;
  771.             DoMethod(obj,MUIM_List_Redraw,pos);
  772.             }
  773.         }
  774.  
  775.     return(DoSuperMethodA(cl,obj,(APTR)msg));
  776. }
  777.  
  778.  
  779. static ULONG ComplexList_ActiveChanged(struct IClass *cl,Object *obj,struct MUIP_EditList_ActiveChanged *msg)
  780. {
  781.     struct ComplexList_Data *data=INST_DATA(cl,obj);
  782.     struct amiga *active;
  783.  
  784.     if (getactive(obj,active)!=MUIV_List_Active_Off)
  785.         {
  786.         set(data->amigaobj,MUIA_Cycle_Active,(ULONG)active->amiga);
  787.         set(data->cpuobj,MUIA_Cycle_Active,(ULONG)active->cpu->cpu);
  788.         set(data->freqobj,MUIA_Numeric_Value,(ULONG)active->cpu->freq);
  789.         set(data->nameobj,MUIA_String_Contents,active->owner->name);
  790.         set(data->ageobj,MUIA_Numeric_Value,(ULONG)active->owner->age);
  791.         set(data->tshirtobj,MUIA_Cycle_Active,(ULONG)active->owner->tshirt);
  792.         }
  793.  
  794.     return(TRUE);
  795. }
  796.  
  797.  
  798. static SAVEDS ASM ULONG ComplexList_Dispatcher(REG(a0) struct IClass *cl,REG(a2) Object *obj,REG(a1) Msg msg)
  799. {
  800.     switch (msg->MethodID)
  801.         {
  802.         case OM_NEW                                    : return(ComplexList_New                (cl,obj,(APTR)msg));
  803.         case OM_SET                                    : return(ComplexList_Set                (cl,obj,(APTR)msg));
  804.         case MUIM_EditList_ActiveChanged        : return(ComplexList_ActiveChanged    (cl,obj,(APTR)msg));
  805.         }
  806.  
  807.     return(DoSuperMethodA(cl,obj,msg));
  808. }
  809.  
  810.  
  811.  
  812.  
  813.  
  814. void ExitClasses()
  815. {
  816.     if (ComplexListClass) MUI_DeleteCustomClass(ComplexListClass);
  817.     if (StringListClass) MUI_DeleteCustomClass(StringListClass);
  818.     if (EditListClass) MUI_DeleteCustomClass(EditListClass);
  819. }
  820.  
  821.  
  822. static VOID fail(Object *app, char *str)
  823. {
  824.     /* Application */
  825.  
  826.     MUI_DisposeObject(app);
  827.  
  828.     /* Classes */
  829.  
  830.     ExitClasses();
  831.  
  832.     /* Libraries */
  833.  
  834.     if (MUIMasterBase) CloseLibrary(MUIMasterBase);
  835.     if (UtilityBase) CloseLibrary(UtilityBase);
  836.  
  837.     if (str)
  838.         {
  839.         puts(str);
  840.         exit(20);
  841.         }
  842.  
  843.     exit(0);
  844. }
  845.  
  846.  
  847. void InitClasses()
  848. {
  849.     if (EditListClass = MUI_CreateCustomClass(NULL,MUIC_Group,NULL,sizeof(struct EditList_Data),EditList_Dispatcher))
  850.         {
  851.         StringListClass = MUI_CreateCustomClass(NULL,NULL,EditListClass,sizeof(struct StringList_Data),StringList_Dispatcher);
  852.         ComplexListClass = MUI_CreateCustomClass(NULL,NULL,EditListClass,sizeof(struct ComplexList_Data),ComplexList_Dispatcher);
  853.         }
  854.  
  855.     if (!((EditListClass) && (StringListClass) && (ComplexListClass)))
  856.         {
  857.         fail(NULL,"Failed to init all custom classes.");
  858.         }
  859. }
  860.  
  861.  
  862. static VOID init(VOID)
  863. {
  864.     /* Libraries */
  865.  
  866.     if (!(UtilityBase = OpenLibrary("utility.library",0)))
  867.         fail(NULL,"Failed to open utility.library.");
  868.  
  869.     if (!(MUIMasterBase = OpenLibrary(MUIMASTER_NAME,MUIMASTER_VMIN)))
  870.         fail(NULL,"Failed to open "MUIMASTER_NAME".");
  871.  
  872.     /* Classes */
  873.  
  874.     InitClasses();
  875. }
  876.  
  877.  
  878. BOOL CheckAsl(ULONG returnid, Object *app, Object *popasl)
  879. {
  880.     if (returnid==MUIV_Application_ReturnID_Quit)
  881.         {
  882.         ULONG active;
  883.  
  884.         get(popasl,MUIA_Popasl_Active,&active);
  885.  
  886.         if (active)
  887.             {
  888.             MUI_Request(app,NULL,0,NULL,"OK",
  889.                 "Cannot quit now, still an asl popup opened.");
  890.             return(1);
  891.             }
  892.         }
  893.  
  894.     return(returnid);
  895. }
  896.  
  897.  
  898.  
  899. int main(int argc,char *argv[])
  900. {
  901.     Object *app,*mainwin,*setwin;
  902.     Object *bu_settings;
  903.     Object *sl_number,*te_displaynumber;
  904.     Object *pa_dir,*te_displaydir;
  905.     Object *pp_pen,*pd_displaypen;
  906.     Object *li_strings,*li_displaystrings;
  907.     Object *li_complex,*li_displaycomplex;
  908.  
  909.     init();
  910.  
  911.     /* Let's create the application object */
  912.  
  913.     app = ApplicationObject,
  914.         MUIA_Application_Title      , "SettingsWindow-Demo",
  915.         MUIA_Application_Version    , "$VER: SettingsWindow-Demo 0.40 (14.12.97)",
  916.         MUIA_Application_Copyright  , "©1997 Ingo Weinhold",
  917.         MUIA_Application_Author     , "Ingo Weinhold",
  918.         MUIA_Application_Description, "SettingsWindow-Demo",
  919.         MUIA_Application_Base       , "SettingsWindow-Demo",
  920.  
  921.         /* the main window */
  922.  
  923.         SubWindow, mainwin = WindowObject,
  924.             MUIA_Window_Title, "SettingsWindow-Demo",
  925.             MUIA_Window_ID, MAKE_ID('S','W','D','E'),
  926.  
  927.             MUIA_Window_Menustrip, MenustripObject,
  928.                 FChild, MenuObject,
  929.                     MUIA_Menu_Title, "Project",
  930.                     FChild, MenuitemObject,
  931.                         MUIA_Menuitem_Title,"Settings...",
  932.                         MUIA_Menuitem_Shortcut,"?",
  933.                         MUIA_UserData, menu_settings,
  934.                         End,
  935.                     FChild, MenuitemObject,
  936.                         MUIA_Menuitem_Title,"Settings MUI...",
  937.                         MUIA_UserData, menu_settingsmui,
  938.                         End,
  939.                     FChild, MenuitemObject,
  940.                         MUIA_Menuitem_Title, NM_BARLABEL,
  941.                         End,
  942.                     FChild, MenuitemObject,
  943.                         MUIA_Menuitem_Title,"About MUI...",
  944.                         MUIA_UserData, menu_aboutmui,
  945.                         End,
  946.                     FChild, MenuitemObject,
  947.                         MUIA_Menuitem_Title, NM_BARLABEL,
  948.                         End,
  949.                     FChild, MenuitemObject,
  950.                         MUIA_Menuitem_Title,"Iconify",
  951.                         MUIA_Menuitem_Shortcut,"i",
  952.                         MUIA_UserData, menu_iconify,
  953.                         End,
  954.                     FChild, MenuitemObject,
  955.                         MUIA_Menuitem_Title,"Quit",
  956.                         MUIA_Menuitem_Shortcut,"q",
  957.                         MUIA_UserData, menu_quit,
  958.                         End,
  959.                     End,
  960.                 End,
  961.  
  962.             WindowContents, VGroup,
  963.                 Child, VGroup,
  964.                     Child, ListviewObject,
  965.                         MUIA_Weight, 50,
  966.                         MUIA_Listview_Input, FALSE,
  967.                         MUIA_Listview_List, FloattextObject,
  968.                             MUIA_Frame, MUIV_Frame_ReadList,
  969.                             MUIA_Background, MUII_ReadListBack,
  970.                             MUIA_Floattext_Text, introtext,
  971.                             MUIA_Floattext_TabSize, 4,
  972.                             MUIA_Floattext_Justify, TRUE,
  973.                             End,
  974.                         End,
  975.  
  976.                     Child, RegisterObject,
  977.                         MUIA_Register_Titles, regtitles,
  978.                         Child, ColGroup(2),
  979.                             Child, Label2("Number:"),
  980.                             Child, te_displaynumber=TextObject,
  981.                                 MUIA_Background, MUII_TextBack,
  982.                                 MUIA_Frame, MUIV_Frame_Text,
  983.                                 End,
  984.  
  985.                             Child, Label2("Directory:"),
  986.                             Child, te_displaydir=TextObject,
  987.                                 MUIA_Background, MUII_TextBack,
  988.                                 MUIA_Frame, MUIV_Frame_Text,
  989.                                 End,
  990.  
  991.                             Child, Label2("Pen:"),
  992.                             Child, pd_displaypen=PendisplayObject,
  993.                                 MUIA_Frame, MUIV_Frame_Text,
  994.                                 MUIA_InnerLeft, 0,
  995.                                 MUIA_InnerTop, 0,
  996.                                 MUIA_InnerRight, 0,
  997.                                 MUIA_InnerBottom, 0,
  998.                                 MUIA_Dropable, FALSE,
  999.                                 End,
  1000.                             End,
  1001.  
  1002.                         Child, ListviewObject,
  1003.                             MUIA_Listview_Input, FALSE,
  1004.                             MUIA_Listview_List, li_displaystrings=ListObject,
  1005.                                 MUIA_Frame, MUIV_Frame_ReadList,
  1006.                                 MUIA_List_ConstructHook, MUIV_List_ConstructHook_String,
  1007.                                 MUIA_List_DestructHook, MUIV_List_DestructHook_String,
  1008.                                 End,
  1009.                             End,
  1010.  
  1011.                         Child, ListviewObject,
  1012.                             MUIA_Listview_Input, FALSE,
  1013.                             MUIA_Listview_List, li_displaycomplex=ListObject,
  1014.                                 MUIA_Frame, MUIV_Frame_ReadList,
  1015.                                 MUIA_List_ConstructHook, &ConstructHook_Complex,
  1016.                                 MUIA_List_DestructHook, &DestructHook_Complex,
  1017.                                 MUIA_List_DisplayHook, &DisplayHook_Complex,
  1018.                                 MUIA_List_Format, ",,,,,",
  1019.                                 MUIA_List_Title, TRUE,
  1020.                                 End,
  1021.                             End,
  1022.                         End,
  1023.                     End,
  1024.  
  1025.                 Child, bu_settings=SimpleButton("Settings..."),
  1026.                 End,
  1027.             End,
  1028.  
  1029.  
  1030.         /* Here comes the SettingsWindow object.
  1031.         **
  1032.         ** Just create it like an ordinary window. The root object you
  1033.         ** supply is put above the Save/Use/Cancel button group.
  1034.         ** Don't use MUIA_Window_Menustrip!
  1035.         **
  1036.         ** To get a "Test" button you must init
  1037.         ** MUIA_SettingsWindow_TestButton, TRUE.
  1038.         */
  1039.  
  1040.         SubWindow, setwin = SettingsWindowObject,
  1041.             MUIA_Window_Title, "SettingsWindow-Demo - Settings",
  1042.             MUIA_Window_ID, MAKE_ID('S','W','S','E'),
  1043.             MUIA_SettingsWindow_TestButton, TRUE,
  1044.  
  1045.             WindowContents, VGroup,
  1046.                 Child, RegisterObject,
  1047.                     MUIA_Register_Titles, regtitles,
  1048.  
  1049.                     Child, ColGroup(2),
  1050.  
  1051.                         Child, Label1("Number:"),
  1052.                         Child, sl_number=SliderObject,
  1053.                             MUIA_Numeric_Min, 1,
  1054.                             MUIA_Numeric_Max, 100,
  1055.                             MUIA_Numeric_Value, 5,
  1056.                             End,
  1057.  
  1058.                         Child, Label2("Directory:"),
  1059.                         Child, pa_dir=PopaslObject,
  1060.                             MUIA_Popstring_String, StringObject,
  1061.                                 MUIA_Frame, MUIV_Frame_String,
  1062.                                 MUIA_String_MaxLen, 256,
  1063.                                 MUIA_String_Contents, "SYS:",
  1064.                                 End,
  1065.                             MUIA_Popstring_Button, PopButton(MUII_PopDrawer),
  1066.                             MUIA_Popasl_Type, ASL_FileRequest,
  1067.                             ASLFR_TitleText, "Select Directory...",
  1068.                             ASLFR_DrawersOnly, TRUE,
  1069.                             End,
  1070.  
  1071.                         Child, Label("Pen:"),
  1072.                         Child, pp_pen=PoppenObject,
  1073.                             End,
  1074.                         End,
  1075.  
  1076.                     Child, li_strings=StringListObject, End,
  1077.  
  1078.                     Child, li_complex=ComplexListObject, End,
  1079.  
  1080.                     End,
  1081.                 End,
  1082.             End,
  1083.  
  1084.         End;
  1085.  
  1086.  
  1087.     if (!app)
  1088.         {
  1089.         fail(NULL,"Failed to create application!\n");
  1090.         }
  1091.  
  1092.  
  1093.     /*** MAINWINDOW ***/
  1094.  
  1095.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,
  1096.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  1097.  
  1098.     /* Menu */
  1099.  
  1100.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_MenuAction,menu_settings,
  1101.         setwin,3,MUIM_Set,MUIA_Window_Open,TRUE);
  1102.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_MenuAction,menu_settingsmui,
  1103.         app,2,MUIM_Application_OpenConfigWindow,0);
  1104.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_MenuAction,menu_iconify,
  1105.         app,3,MUIM_Set,MUIA_Application_Iconified,TRUE);
  1106.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_MenuAction,menu_aboutmui,
  1107.         app,2,MUIM_Application_AboutMUI,mainwin);
  1108.     DoMethod(mainwin,MUIM_Notify,MUIA_Window_MenuAction,menu_quit,
  1109.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  1110.  
  1111.     /* Pressing the settings button implies opening the settings window */
  1112.  
  1113.     DoMethod(bu_settings,MUIM_Notify,MUIA_Pressed,FALSE,
  1114.         setwin,3,MUIM_Set,MUIA_Window_Open,TRUE);
  1115.  
  1116.  
  1117.     /*** SETTINGSWINDOW ***/
  1118.  
  1119.     /* Notify when the user has set another...*/
  1120.  
  1121.     /* ... Number: */
  1122.  
  1123.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_number,MUIV_EveryTime,
  1124.         te_displaynumber,4,MUIM_SetAsString,MUIA_Text_Contents,"%ld",MUIV_TriggerValue);
  1125.  
  1126.     /* ... Directory: */
  1127.  
  1128.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_dir,MUIV_EveryTime,
  1129.         te_displaydir,3,MUIM_Set,MUIA_Text_Contents,MUIV_TriggerValue);
  1130.  
  1131.     /* ... Pen: */
  1132.  
  1133.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_pen,MUIV_EveryTime,
  1134.         pd_displaypen,3,MUIM_Set,MUIA_Pendisplay_Spec,MUIV_TriggerValue);
  1135.  
  1136.  
  1137.     /* ... Listcontents
  1138.     **
  1139.     **    First clear the list, then insert all entries.
  1140.     */
  1141.  
  1142.     /* StringList */
  1143.  
  1144.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_strlist,MUIV_EveryTime,
  1145.         li_displaystrings,1,MUIM_List_Clear);
  1146.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_strlist,MUIV_EveryTime,
  1147.         li_displaystrings,4,MUIM_List_Insert,MUIV_TriggerValue,-1,MUIV_List_Insert_Bottom);
  1148.  
  1149.     /* ComplexList */
  1150.  
  1151.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_cpxlist,MUIV_EveryTime,
  1152.         li_displaycomplex,1,MUIM_List_Clear);
  1153.     DoMethod(setwin,MUIM_SettingsWindow_Notify,setid_cpxlist,MUIV_EveryTime,
  1154.         li_displaycomplex,4,MUIM_List_Insert,MUIV_TriggerValue,-1,MUIV_List_Insert_Bottom);
  1155.  
  1156.  
  1157.     /*    Initialize the SettingsWindow
  1158.     **
  1159.     ** Doing it after setting up the notifications causes that the
  1160.     ** notification methods are executed if old settings could be loaded.
  1161.     */
  1162.  
  1163.     DoMethod(setwin,MUIM_SettingsWindow_Init,
  1164.         sl_number,MUIA_Numeric_Value,SWIT_STANDARD,0,setid_number,
  1165.         pa_dir,MUIA_String_Contents,SWIT_STRING,256,setid_dir,
  1166.         pp_pen,MUIA_Pendisplay_Spec,SWIT_STRUCT,sizeof(struct MUI_PenSpec),setid_pen,
  1167.         li_strings,0,SWIT_LISTSTRING,-1,setid_strlist,
  1168.         li_complex,0,SWIT_LISTCOMPLEX,amiga_des,setid_cpxlist,
  1169.         NULL);
  1170.  
  1171.  
  1172.     /* Open the main window */
  1173.  
  1174.     set(mainwin,MUIA_Window_Open,TRUE);
  1175.  
  1176.     /* The main loop is slightly changed to make sure that the ASL
  1177.     ** requester is closed when exiting.
  1178.     */
  1179.  
  1180.         {
  1181.         ULONG sigs = 0;
  1182.  
  1183.         while (CheckAsl(DoMethod(app,MUIM_Application_NewInput,&sigs),
  1184.             app, pa_dir) != MUIV_Application_ReturnID_Quit)
  1185.             {
  1186.             if (sigs)
  1187.                 {
  1188.                 sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  1189.                 if (sigs & SIGBREAKF_CTRL_C) break;
  1190.                 }
  1191.             }
  1192.         }
  1193.  
  1194.     set(mainwin,MUIA_Window_Open,FALSE);
  1195.  
  1196.     fail(app,NULL);
  1197. }
  1198.  
  1199.  
  1200.